<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Example Documentation</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.18 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="examples.html">Examples</a> &nbsp; </center>
<hr><h1>/TestCOMGraphan/TestCOMGraphan.cpp</h1>
<p>
<div class="fragment"><pre><span class="comment">/*</span>
<span class="comment"> This example loads the input file into graphematics and prints </span>
<span class="comment"> all found English words.</span>
<span class="comment">*/</span>

<span class="preprocessor">#include &lt;stdio.h&gt;</span>
<span class="preprocessor">#include "string.h"</span>
<span class="preprocessor">#include &lt;string&gt;</span>
<span class="preprocessor">#import "../../bin/graphan.tlb"</span>
<span class="preprocessor"></span>




<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
{       
        <span class="keywordflow">if</span> (argc != 2)
        {
                printf (<span class="stringliteral">"TestComGraphan, Test for Dialing Graphematical Analysis(COM)(www.aot.ru)\n"</span>);
                printf (<span class="stringliteral">"Usage: TestComGraphan &lt;file&gt;\n"</span>);
                printf (<span class="stringliteral">"where file is an text or html file\n"</span>);
                <span class="keywordflow">return</span> 1;
        };
        <span class="comment">// init COM</span>
        CoInitialize(NULL);

        GRAPHANLib::IGraphmatFilePtr piGraphan;
        
        <span class="comment">// creating COM-object</span>
        HRESULT hr = piGraphan.CreateInstance(__uuidof(GRAPHANLib::GraphmatFile));
        <span class="keywordflow">if</span> (FAILED (hr))
        {
                printf (<span class="stringliteral">"Graphan is not registered"</span>);
                CoUninitialize();
                <span class="keywordflow">return</span> 1;
        };

        <span class="comment">// loading dictionaries </span>
        hr = piGraphan-&gt;LoadDicts();

        piGraphan-&gt;Language = 1;

        <span class="comment">// write the graphematical table to .gra file </span>
        piGraphan-&gt;GraOutputFile = <span class="stringliteral">"out.gra"</span>;

        <span class="comment">// write the graphematical macro syntax structure .xml file </span>
        piGraphan-&gt;XmlMacSynOutputFile = <span class="stringliteral">"out.xml"</span>;

        <span class="comment">//  loading file</span>
        printf (<span class="stringliteral">"Loading file %s\n"</span>, argv[1]);
        piGraphan-&gt;LoadFileToGraphan(argv[1]);
        

        <span class="comment">// get the number of rows in the graphematical table</span>
        size_t Count = piGraphan-&gt;GetLineCount();
        printf (<span class="stringliteral">"Found Units %i\n"</span>, Count);

        <span class="comment">// print all words which are written in English ABC</span>
    <span class="keywordflow">for</span> (size_t i =0; i&lt; Count; i++)
                <span class="keywordflow">if</span> (piGraphan-&gt;HasDescr(i,GRAPHANLib::OLLE) == TRUE)
           {
                   std::string s = (<span class="keyword">const</span> <span class="keywordtype">char</span>*) piGraphan-&gt;GetWord (i);  <span class="comment">// get the token</span>
                   printf (<span class="stringliteral">"%s\n"</span>, s.c_str()); 

           };
        piGraphan = 0;
        CoUninitialize();
        <span class="keywordflow">return</span> 0;
}


</pre></div><hr><address style="align: right;"><small>Generated on Sat Jun 25 17:04:48 2005 for Graphan by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.18 </small></address>
</body>
</html>
